﻿using Experiment2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cprojeket
{
    class main
    {
        static void Main(string[] args)
        {
            //第一题
            Console.WriteLine("第一题");
            Album album = new Album(2);
            Photo file1 = new Photo("陈寒");
            Photo file2 = new Photo("chenhan");
            //向相册加载图片
            album[0] = file1;
            album[1] = file2;
            //按索引加载图片
            Photo pritp = album[1];
            Console.WriteLine(pritp.PhotoName);
            //按名称索引
            pritp = album["陈寒"];
            Console.WriteLine(pritp.PhotoName);
            pritp = album["美图"];
      
            //第二题
            Console.WriteLine("第二题");
            Console.WriteLine("接口");
            ICollectHomeworkable teacher = new Teacher();
            ICollectHomeworkable student = new Student();
            teacher.Collect();
            student.Collect();



            //第三题
            Console.WriteLine("第三题");
            //委托对象
            Delegate1 objDelegate = new Delegate1();
            classA objclassA = new classA();
            classB objclassB = new classB();
            //订阅事件
            objDelegate.NotifyEveryOne += new Delegate1.MeDelegate(objclassA.DisMethod);
            objDelegate.NotifyEveryOne += new Delegate1.MeDelegate(objclassB.DisMethod);
            //触发事件
            objDelegate.Notify();





            //银行还款
            //1.创建储蓄卡集合
            DepositCard D1 = new DepositCard("工商银行", 1000);
            DepositCard D2 = new DepositCard("农业银行", 2000);
            DepositCard[] Dc = { D1, D2};
            DepositCards cards = new DepositCards(Dc,2);


            //2.创建信用卡对象
            CreditCard C1 = new CreditCard("小明", 1010, 1, cards);
            CreditCard C2 = new CreditCard("小红", 4000, 1, cards);
            List<CreditCard> creditCards = new List<CreditCard>();
            creditCards.Add(C1);
            creditCards.Add(C2);
            //创建委托
            RepayDelegate RD = new RepayDelegate();
            //判断时间
            foreach (CreditCard creditCard in creditCards)
            {
                if (creditCard.DueDay == int.Parse(DateTime.Now.ToString("yyyy-mm-dd").Split('-')[2]))
                {
                    //事件添加
                    RD.Dorepay += new RepayDelegate.RepayMoney(creditCard.Repaym);
                }
                else
                {
                    RD.Dorepay += new RepayDelegate.RepayMoney(creditCard.Norepaym);
                }
            }
            //事件执行
            RD.NotifyRepay();
            Console.ReadKey();
        }
    }
}


